#include "RegisterNumberInfoCollection.h"

RegisterNumberInfoCollection::RegisterNumberInfoCollection(QObject *parent) : InfoCollectionBase(parent)
{

}

QString RegisterNumberInfoCollection::getSerialNumber()
{
    QString retStr;
    if (QDBusConnection::systemBus().isConnected())
    {
        QScopedPointer<QDBusInterface> dbusInterface(new QDBusInterface(s_serverName,s_objectPath,s_interfaceName,QDBusConnection::systemBus()));
        if (!dbusInterface.isNull())
        {
            QDBusMessage dbusMessage = dbusInterface->call(s_methodName);
            if (dbusMessage.type() == QDBusMessage::MessageType::ReplyMessage
                    && !dbusMessage.arguments().isEmpty()
                    && dbusMessage.arguments().size() == 2)
            {
                QList<QVariant> retValue = dbusMessage.arguments();
                if (retValue.last().toInt() == 0)
                {
                    retStr = retValue.first().toString();
                }
            }
        }

    }
    return retStr;
}
